package com.imy.virtual.client.fake;

import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.Toast;

import java.net.NetworkInterface;

import de.robv.android.xposed.DexposedBridge;
import de.robv.android.xposed.XC_MethodHook;

public class NetHook {
  private static Handler mHandler =new Handler(Looper.getMainLooper());
  public static void start(final Context context) {
    DexposedBridge.findAndHookMethod(NetworkInterface.class, "getInetAddresses", new XC_MethodHook() {
      @Override
      protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
        super.beforeHookedMethod(param);
        mHandler.post(new Runnable() {
          @Override
          public void run() {
            Toast.makeText(context,"检测发现调用隐私权限",Toast.LENGTH_LONG).show();
          }
        });
      }
    });
    DexposedBridge.findAndHookMethod(TelephonyManager.class, "getDeviceId", new XC_MethodHook() {
      @Override
      protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
        super.beforeHookedMethod(param);
        Log.i("NetHook","hook:");
        Toast.makeText(context,"调用getDeviceId ",Toast.LENGTH_LONG).show();
      }
    });



  }
}
